package com.wpp.lagouserviceemail.controller;

import com.wpp.core.email.SendEmailParam;
import com.wpp.lagouserviceemail.service.MailService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author wpp25
 * @date 2021/5/16 21:42
 * @description：
 */
@RestController
@RequestMapping("/api/email")
public class EmailController {

    @Resource
    private MailService mailService;


    @PostMapping("/sendSimpleEmail")
    public void sendSimpleMail(@RequestBody SendEmailParam sendEmailParam){
        mailService.sendSimpleMail(sendEmailParam.getReceiveEmail(),sendEmailParam.getReceiveEmail(),sendEmailParam.getContent());
    }

    @GetMapping("/sendEmail")
    public void sendEmail(@RequestParam("email") String email,
                          @RequestParam("content") String content,
                          @RequestParam("subject") String subject){

        SendEmailParam sendEmailParam = new SendEmailParam();
        sendEmailParam.setReceiveEmail(email);
        sendEmailParam.setSubject(subject);
        sendEmailParam.setContent(content);
        mailService.sendSimpleMail(sendEmailParam.getReceiveEmail(),sendEmailParam.getReceiveEmail(),sendEmailParam.getContent());
    }
}
